<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<div class="hp-page" th:fragment="pagination(page, uri)">
    <a th:href="@{${uri} + 'page=1&page_size=' + ${page.getSize()}}"
       th:if="${page.getNumber()} > 0">首页</a>

    <a th:href="@{${uri} + 'page=' + ${page.getNumber()} +  '&page_size=' + ${page.getSize()}}"
       th:if="${page.hasPrevious()}">上一页</a>

    <!--
    Thymeleaf简单分页：https://blog.csdn.net/qq_32719215/article/details/94400725
    Thymeleaf分页组件：https://www.jianshu.com/p/60ac23c092c0
    -->
    <a th:href="@{${uri} + 'page=' + ${pageNum} + '&page_size=' + ${page.getSize()}}"
       th:each="pageNum : ${#numbers.sequence(1, page.getTotalPages())}"
       th:class="${page.getNumber() + 1 == pageNum} ? 'active'"
       th:text="${pageNum}"></a>

    <a th:href="@{${uri} + 'page=' + ${page.getNumber() + 2} +  '&page_size=' + ${page.getSize()}}"
       th:if="${page.hasNext()}">下一页</a>

    <a th:href="@{${uri} + 'page=' + ${page.getTotalPages()} + '&page_size=' + ${page.getSize()}}"
       th:if="${page.getNumber()} < ${page.getTotalPages() - 1}">末页</a>
</div>
</html>